﻿@using BestTrader.Cms.Models
@using BestTrader.Cms.ViewModels
@model List<ServiceChargeListModel>
@{
    ViewData["Title"] = "手续费设置";
    var UnitNames = new Dictionary<string, string>() { { "HKD", "港币" }, { "USD", "美元" }, { "EUR", "欧元" }, { "JPY", "日元" }, { "CNY", "人民币" } };
    var ServiceCharges = ViewData["ServiceCharges"] as List<ServiceChargeListModel>;
    var TradeCommissions = ViewData["TradeCommissions"] as List<TradeCommissionListModel>;
}

<form class="layui-form layui-form-pane" style="width:90%;">
    @Html.AntiForgeryToken()
    <input id="Id" name="Id" class="Id" type="hidden" value="@(ViewData["ManagerId"])" />
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label" style="width: 200px; border-radius: 2px 0 0 2px;"><strong>品种名称(代码,货币)</strong></label>
        <label class="layui-form-label" style="width: 200px; border-radius:0; border-left-width: 0;"><strong>佣金</strong></label>
        <label class="layui-form-label" style="width: 200px; border-radius:0; border-left-width: 0;"><strong>成本</strong></label>
        @*<label class="layui-form-label" style="width: 360px; border-radius:0 2px 2px 0; border-left-width: 0;"><strong>备注</strong></label>*@
    </div>
    @if (ServiceCharges != null && TradeCommissions != null && Model != null)
    {
        foreach (var serviceCharge in ServiceCharges)
        {
            if (serviceCharge.ProjectPrice.HasValue && serviceCharge.ProjectPrice > 0)
            {
                foreach (var tradeCommission in TradeCommissions)
                {
                    if (tradeCommission.ProjectCode == serviceCharge.ProjectCode)
                    {
                        var findId = 0;
                        int? findManagerId = null;
                        decimal? findValue = null;
                        decimal? findAgentTrade = null;
                        decimal? findSalesTrade = null;
                        foreach (var item in Model)
                        {
                            if (item.ProjectCode == serviceCharge.ProjectCode)
                            {
                                findId = item.Id;
                                findManagerId = item.ProjectManagerId;
                                findValue = item.ProjectPrice;
                                findAgentTrade = item.AgentTrade;
                                findSalesTrade = item.SalesTrade;
                            }
                        }
                        <div class="layui-form-item layui-row layui-col-xs12">
                            <label class="layui-form-label" style="width: 200px;">@(serviceCharge.ProjectName)(@(serviceCharge.ProjectCode),@(UnitNames[serviceCharge.ProjectUnit]))</label>
                            <div class="layui-input-inline" style="margin-right: 0; width:200px;">
                                <input type="text" class="layui-input service1 AgentTrade" value="@(findAgentTrade)" lay-verify="service1" style="width:100%;" placeholder="请录入佣金" />
                            </div>
                            <div class="layui-input-inline" style="width:200px;">
                                <input type="text" class="layui-input service2 SalesTrade" value="@(findSalesTrade)" lay-verify="service2" style="width:100%;" placeholder="请录入成本" />
                                <input type="hidden" id="@(findId)" name="@(tradeCommission.ProjectCode)" class="layui-input service" lay-verify="service" placeholder="0" tag="@(serviceCharge.ProjectName)(@(serviceCharge.ProjectCode),@(UnitNames[serviceCharge.ProjectUnit]))" chargeName="@(serviceCharge.ProjectName)" chargeUnit="@(serviceCharge.ProjectUnit)" trade="@(tradeCommission.ProjectPrice)" charge="@(serviceCharge.ProjectPrice)" value="@(findValue)" maxlength="6">
                            </div>
                            <div class="layui-form-mid layui-word-aux"><a class="hisstroy" title="历史记录" key="@(findManagerId)" code="@(tradeCommission.ProjectCode)"><i class="layui-icon">&#xe60a;</i></a></div>
                            @*<div class="layui-form-mid layui-word-aux">单边模式(标准手续费为@(tradeCommission.ProjectPrice))>总手续费:@(serviceCharge.ProjectPrice)</div>*@
                        </div>
                    }
                }
            }
        }
    }

    <div class="layui-form-item layui-row layui-col-xs-offset1 layui-col-xs5">
        <div class="layui-input-inline">
            <button class="layui-btn layui-btn-sm layui-btn-fluid" lay-submit="" lay-filter="service">确定</button>
        </div>
    </div>
</form>
@section Scripts{
    <script type="text/javascript" src="~/layui/layui.js"></script>
    <script type="text/javascript" src="~/js/tradecommission/settingtradeAdd.js?_=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
}



